home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 80 / CD Actual 80 Julio-Agosto 2003.iso / Linux / LinuxGazette / lg / issue39 / rogers_example05b.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-14  |  650 b   |  40 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /*
  5.  
  6.     This program is written to demonstrate the <stdlib.h> library.
  7.  
  8.     This program will demonstrate string to number conversions
  9.  
  10.     Written by James M. Rogers
  11.  
  12.     17 March 1999
  13.  
  14.     Released to the Public Domain on this date.
  15.  
  16. */
  17.  
  18. main(){
  19.  
  20.     double a;
  21.     int b;
  22.     long int c;
  23.     unsigned long int d;
  24.  
  25.  
  26.     a = atof("1345");
  27.     printf("%f\n", a);
  28.     b = atoi("-345");
  29.     printf("%d\n", b);
  30.     c = atol("1234567890");
  31.     printf("%d\n", c);
  32.     a = strtod("9876543210.0123456789", (char **)NULL);
  33.     printf("%f\n", a);
  34.     c = strtol("157", (char **)NULL, 10);
  35.     printf("%d\n", c);
  36.     d = strtoul("47586", (char **)NULL, 10);
  37.     printf("%d\n", d);
  38.  
  39. }
  40.